/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Practica2;

import com.sun.org.apache.bcel.internal.generic.TABLESWITCH;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author RUDY
 */
public class frmPractica2 extends javax.swing.JFrame {

    DefaultListModel lista=new  DefaultListModel();
    DefaultTableModel tabla;
    DefaultTableModel tablap=new DefaultTableModel();
    DefaultTableModel tablac=new DefaultTableModel();
    DefaultTableModel tablapc;
    public Object[] cp={"nombre_cliente","numero_prestamo"};
    public Object[] cc={"nombre_cliente","calle_cliente","ciudad_cliente"};
    public Object[] cpc={"nombre_cliente","numero_prestamo","calle_cliente","ciudad_cliente"};

    /**
     * Creates new form frmPractica2
     */
    public frmPractica2() {
        initComponents();
        this.setLocationRelativeTo(null);
        tablac.setColumnIdentifiers(cc); 
        tabla_cliente.setModel(tablac); 
        tablap.setColumnIdentifiers(cp);       
        tabla_prestatario.setModel(tablap); 
        //memoria_intermedia.setModel(lista);           
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        table_mi = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        bdd2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        bmi2 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        bclru = new javax.swing.JButton();
        bc_lru = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        bmi1 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        bdd1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        btnMRU = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        btnLRU = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        bmi = new javax.swing.JTextField();
        bdd = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        pname = new javax.swing.JTextField();
        pnro = new javax.swing.JTextField();
        addprestatario = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        cciudad = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        cname = new javax.swing.JTextField();
        ccalle = new javax.swing.JTextField();
        addcliente = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla_prestatario = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabla_p_c = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        tabla_cliente = new javax.swing.JTable();
        process_p_c = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        table_mi.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(table_mi);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Bloques Clavados - LRU"));

        jLabel6.setText("Bloques_Disco Duro :");

        jLabel5.setText("Bloques_Memoria Intermedia :");

        bclru.setText("BC_LRU");
        bclru.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bclruActionPerformed(evt);
            }
        });

        jLabel7.setText("Bloque Clavado :");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(bmi2)
                            .addComponent(bdd2, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                            .addComponent(bc_lru)))
                    .addComponent(bclru))
                .addContainerGap(52, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bdd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bmi2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bc_lru, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(bclru))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("MRU"));

        jLabel4.setText("Bloques_Disco Duro :");

        jLabel3.setText("Bloques_Memoria Intermedia :");

        btnMRU.setText("MRU");
        btnMRU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMRUActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(bmi1)
                            .addComponent(bdd1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnMRU))
                .addContainerGap(44, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bdd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bmi1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnMRU))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("LRU"));

        btnLRU.setText("LRU");
        btnLRU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLRUActionPerformed(evt);
            }
        });

        jLabel1.setText("Bloques_Disco Duro :");

        jLabel2.setText("Bloques_Memoria Intermedia :");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(32, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(bmi, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                    .addComponent(bdd))
                .addGap(31, 31, 31))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnLRU)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bmi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(btnLRU))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Gestor de Memoria Intermedia", jPanel4);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Prestatario"));

        jLabel8.setText("Nombre cliente :");

        jLabel9.setText("Nro Prestamo :");

        addprestatario.setText("Agregar");
        addprestatario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addprestatarioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(pname, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                            .addComponent(pnro)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(addprestatario)))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(pname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(pnro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addComponent(addprestatario)
                .addContainerGap())
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Cliente"));

        jLabel10.setText("Nombre cliente :");

        jLabel11.setText("Calle Cliente :");

        jLabel12.setText("Ciudad Cliente :");

        addcliente.setText("Agregar");
        addcliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addclienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel10)
                        .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(addcliente)
                    .addComponent(cname, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                    .addComponent(ccalle)
                    .addComponent(cciudad))
                .addContainerGap(37, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(cname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(ccalle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12)
                    .addComponent(cciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(addcliente)
                .addGap(14, 14, 14))
        );

        tabla_prestatario.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "nombre_cliente", "numero_prestamo"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tabla_prestatario);

        tabla_p_c.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "nombre_cliente", "numero_prestamo", "calle_cliente", "ciudad_cliente"
            }
        ));
        jScrollPane3.setViewportView(tabla_p_c);

        tabla_cliente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "nombre_cliente", "calle_cliente", "ciudad_cliente"
            }
        ));
        jScrollPane4.setViewportView(tabla_cliente);

        process_p_c.setText("Prestatario | x | Cliente");
        process_p_c.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                process_p_cActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(56, 56, 56)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 95, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(55, 55, 55))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3)
                .addContainerGap())
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 429, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(process_p_c, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(process_p_c)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("prestatario |x| cliente", jPanel5);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnLRUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLRUActionPerformed
        // TODO add your handling code here:
        lista.clear();
        tabla=new DefaultTableModel();
        table_mi.setModel(tabla);
        int bloques_dd=Integer.parseInt(bdd.getText());
        int bloques_mi=Integer.parseInt(bmi.getText()); 
        Integer [] columns=new Integer[bloques_mi];
        for(int v=0;v<bloques_mi;v++)
        {
            columns[v]=v+1;
        }
        tabla.setColumnIdentifiers(columns);
        //if(bloques_mi<bloques_dd)
        //{
            Object[] bloques=new Object[bloques_mi];
            for(int x=0;x<bloques_mi;x++)
            {
                bloques[x]=" ";
            }
            int y=0;
            for(int i=1;i<=bloques_dd;i++)
            {         
                y++;
                if(y>bloques_mi)
                {
                    //System.out.print("hola");
                    y=y%bloques_mi;
                    if(y==0)
                    {y=bloques_mi;}
                }
                for(int r=1;r<=bloques_mi;r++)
                {                 
//                    for(int j=0;j<bloques_mi;j++)
//                    {
                        //if(r==j)
                        //System.out.print("r:"+r+" y:"+y+"\n");
                        if(y==r)
                        {
                            //System.out.print("si \n");
                            bloques[r-1]="r"+i;   
                            //System.out.print(i+"\n");
                            r=bloques_mi;
                            
                        }
//                    }            
                } 
                
                //mostrarlista(bloques);
                mostrartabla(bloques);
            }
        //}
       
        //memoria_intermedia.getModel(lista);
    }//GEN-LAST:event_btnLRUActionPerformed

    private void btnMRUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMRUActionPerformed
        // TODO add your handling code here:
        lista.clear();
        tabla=new DefaultTableModel();
        table_mi.setModel(tabla);
        int bloques_dd=Integer.parseInt(bdd1.getText());
        int bloques_mi=Integer.parseInt(bmi1.getText()); 
        Integer [] columns=new Integer[bloques_mi];
        for(int v=0;v<bloques_mi;v++)
        {
            columns[v]=v+1;
        }
        tabla.setColumnIdentifiers(columns);
            Object[] bloques=new Object[bloques_mi];
            for(int x=0;x<bloques_mi;x++)
            {
                bloques[x]=" ";
            }
            int y=0;
            for(int i=1;i<=bloques_dd;i++)
            {         
                y++;
                if(y>=bloques_mi)
                {
                    y=bloques_mi;
                }
                for(int r=1;r<=bloques_mi;r++)
                {                 
                        if(y==r)
                        {
                            bloques[r-1]="r"+i;   
                            r=bloques_mi;                            
                        } 
                } 
                
                mostrartabla(bloques);
            }
    }//GEN-LAST:event_btnMRUActionPerformed

    private void bclruActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bclruActionPerformed
        // TODO add your handling code here:
        lista.clear();
        tabla=new DefaultTableModel();
        table_mi.setModel(tabla);
        int bloques_dd=Integer.parseInt(bdd2.getText());
        int bloques_mi=Integer.parseInt(bmi2.getText()); 
        int bloque_clavado=Integer.parseInt(bc_lru.getText()); 
        Integer [] columns=new Integer[bloques_mi];
        for(int v=0;v<bloques_mi;v++)
        {
            columns[v]=v+1;
        }
        tabla.setColumnIdentifiers(columns);
            Object[] bloques=new Object[bloques_mi];
            for(int x=0;x<bloques_mi;x++)
            {
                bloques[x]=" ";
            }
            int y=0;
            for(int i=1;i<=bloques_dd;i++)
            {         
                y++;
                if(y>bloques_mi)
                {
                    y=y%bloques_mi;
                    if(y==0)
                    {y=bloques_mi;}
                }
                for(int r=1;r<=bloques_mi;r++)
                {          
                    if(i>bloques_mi&y==bloque_clavado)
                    {
                        if(y==bloques_mi)
                        {
                            y=1;
                        }
                        else
                        {
                            y++;
                        }
                    }
                    if(y==r)
                    {
                        bloques[r-1]="r"+i;   
                        r=bloques_mi;
                    }
                } 
                mostrartabla(bloques);
            }        
    }//GEN-LAST:event_bclruActionPerformed

    private void addprestatarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addprestatarioActionPerformed
        // TODO add your handling code here:    
        if(!pname.getText().isEmpty()&!pnro.getText().isEmpty())
        {
            Object[] prestatarios={pname.getText(),pnro.getText()};
            tablap.addRow(prestatarios);
            pname.setText("");
            pnro.setText("");
        }
        else
        {
            JOptionPane.showMessageDialog(frmPractica2.this,"ERROR \n Llene todos los campos del prestatario ", "ATENCION", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_addprestatarioActionPerformed

    private void addclienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addclienteActionPerformed
        // TODO add your handling code here:       
        if(!cname.getText().isEmpty()&!ccalle.getText().isEmpty()&!cciudad.getText().isEmpty())
        {
            Object[] cliente={cname.getText(),ccalle.getText(),cciudad.getText()};
            tablac.addRow(cliente);
            cname.setText("");
            ccalle.setText("");
            cciudad.setText("");
        }
        else
        {
            JOptionPane.showMessageDialog(frmPractica2.this,"ERROR \n Llene todos los campos del cliente ", "ATENCION", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_addclienteActionPerformed

    private void process_p_cActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_process_p_cActionPerformed
        // TODO add your handling code here:
//            for each tupla p de prestatario do
//                for each tupla c de cliente do
//                    if p[nombre-cliente] = c [nombre-cliente]
//                        then begin
//                            sea x una tupla definida de la manera siguiente:
//                            x[nombre-cliente] := p [nombre-cliente]
//                            x[número-préstamo] := p [número-préstamo]
//                            x[calle-cliente ] := c [calle-cliente ]
//                            x[ciudad-cliente ] := c [ciudad-cliente ]
//                            incluir la tupla x como parte del resultado de prestatario |X| cliente
//                    end
//                end
//            end
        tablapc= new DefaultTableModel();
        
        tablapc.setColumnIdentifiers(cpc);
        tabla_p_c.setModel(tablapc);
        
        int filas_p=tablap.getRowCount();
        int filas_c=tablac.getRowCount();
        for(int x=0;x<filas_p;x++)
        {
            for(int y=0;y<filas_c;y++)
            {
                if(tabla_prestatario.getValueAt(x, 0).equals(tabla_cliente.getValueAt(y, 0)))
                {
                    Object xnombre_cliente=tabla_prestatario.getValueAt(x, 0);
                    Object xnumero_prestamo=tabla_prestatario.getValueAt(x, 1);
                    Object xcalle_cliente=tabla_cliente.getValueAt(y, 1);
                    Object xciudad_cliente=tabla_cliente.getValueAt(y, 2);
                    Object[] join={xnombre_cliente,xnumero_prestamo,xcalle_cliente,xciudad_cliente};
                    tablapc.addRow(join);
                }
            }
        }
    }//GEN-LAST:event_process_p_cActionPerformed

    public void mostrarlista(Object[] bloques)
    {
         String fila="";
         for(int i=0;i<bloques.length;i++)
         {
             fila+=bloques[i].toString()+" | ";
         }
         lista.addElement(fila);
         
    }
    public void mostrartabla(Object[] bloques)
    {
         tabla.addRow(bloques);
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmPractica2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmPractica2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmPractica2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmPractica2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmPractica2().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addcliente;
    private javax.swing.JButton addprestatario;
    private javax.swing.JTextField bc_lru;
    private javax.swing.JButton bclru;
    private javax.swing.JTextField bdd;
    private javax.swing.JTextField bdd1;
    private javax.swing.JTextField bdd2;
    private javax.swing.JTextField bmi;
    private javax.swing.JTextField bmi1;
    private javax.swing.JTextField bmi2;
    private javax.swing.JButton btnLRU;
    private javax.swing.JButton btnMRU;
    private javax.swing.JTextField ccalle;
    private javax.swing.JTextField cciudad;
    private javax.swing.JTextField cname;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField pname;
    private javax.swing.JTextField pnro;
    private javax.swing.JButton process_p_c;
    private javax.swing.JTable tabla_cliente;
    private javax.swing.JTable tabla_p_c;
    private javax.swing.JTable tabla_prestatario;
    private javax.swing.JTable table_mi;
    // End of variables declaration//GEN-END:variables
}
